package cetcbigdata.da.personal_corporate_matters_guide.hubei;

import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

public class MyJsUtil {

    private static String jsCode = "//获取自然人事项主题\n" +
            "function getSxzt2(sxzt) {\n" +
            "    var z = [];\n" +
            "    var sxzt2 = sxzt.split(\",\");\n" +
            "    for (var i = 0; i < sxzt2.length; i++) {\n" +
            "        switch (sxzt2[i]) {\n" +
            "            case \"005\":\n" +
            "                z[i] = \"生育收养\";\n" +
            "                break;\n" +
            "            case \"010\":\n" +
            "                z[i] = \"户籍办理\";\n" +
            "                break;\n" +
            "            case \"015\":\n" +
            "                z[i] = \"民族宗教\";\n" +
            "                break;\n" +
            "            case \"020\":\n" +
            "                z[i] = \"教育科研\";\n" +
            "                break;\n" +
            "            case \"025\":\n" +
            "                z[i] = \"入伍服役\";\n" +
            "                break;\n" +
            "            case \"030\":\n" +
            "                z[i] = \"就业创业\";\n" +
            "                break;\n" +
            "            case \"035\":\n" +
            "                z[i] = \"设立变更\";\n" +
            "                break;\n" +
            "            case \"040\":\n" +
            "                z[i] = \"准营准办\";\n" +
            "                break;\n" +
            "            case \"045\":\n" +
            "                z[i] = \"抵押质押\";\n" +
            "                break;\n" +
            "            case \"050\":\n" +
            "                z[i] = \"职业资格\";\n" +
            "                break;\n" +
            "            case \"055\":\n" +
            "                z[i] = \"行政缴费\";\n" +
            "                break;\n" +
            "            case \"060\":\n" +
            "                z[i] = \"婚姻登记\";\n" +
            "                break;\n" +
            "            case \"065\":\n" +
            "                z[i] = \"优待抚恤\";\n" +
            "                break;\n" +
            "            case \"070\":\n" +
            "                z[i] = \"规划建设\";\n" +
            "                break;\n" +
            "            case \"075\":\n" +
            "                z[i] = \"住房保障\";\n" +
            "                break;\n" +
            "            case \"085\":\n" +
            "                z[i] = \"社会保障（社会保险、社会救助）\";\n" +
            "                break;\n" +
            "            case \"090\":\n" +
            "                z[i] = \"证件办理\";\n" +
            "                break;\n" +
            "            case \"095\":\n" +
            "                z[i] = \"交通出行\";\n" +
            "                break;\n" +
            "            case \"100\":\n" +
            "                z[i] = \"旅游观光\";\n" +
            "                break;\n" +
            "            case \"105\":\n" +
            "                z[i] = \"出境入境\";\n" +
            "                break;\n" +
            "            case \"110\":\n" +
            "                z[i] = \"消费维权\";\n" +
            "                break;\n" +
            "            case \"115\":\n" +
            "                z[i] = \"公共安全\";\n" +
            "                break;\n" +
            "            case \"120\":\n" +
            "                z[i] = \"司法公证\";\n" +
            "                break;\n" +
            "            case \"125\":\n" +
            "                z[i] = \"知识产权\";\n" +
            "                break;\n" +
            "            case \"130\":\n" +
            "                z[i] = \"环保绿化\";\n" +
            "                break;\n" +
            "            case \"135\":\n" +
            "                z[i] = \"文化体育\";\n" +
            "                break;\n" +
            "            case \"140\":\n" +
            "                z[i] = \"公用事业\";\n" +
            "                break;\n" +
            "            case \"145\":\n" +
            "                z[i] = \"医疗卫生\";\n" +
            "                break;\n" +
            "            case \"150\":\n" +
            "                z[i] = \"离职退休\";\n" +
            "                break;\n" +
            "            case \"155\":\n" +
            "                z[i] = \"死亡殡葬\";\n" +
            "                break;\n" +
            "            case \"998\":\n" +
            "                z[i] = \"地方特色分类\";\n" +
            "                break;\n" +
            "            case \"999\":\n" +
            "                z[i] = \"其他\";\n" +
            "                break;\n" +
            "        }\n" +
            "    }\n" +
            "    return z.toString();\n" +
            "}";

    public static String getData111111111111111(String code){
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("js");
        //编写js方法体
        try {
            engine.eval(jsCode);
            //执行js脚本。
            Invocable invocable = (Invocable) engine;
            Object object = invocable.invokeFunction("getSxzt2", code);
            System.out.println(object);
            return object.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        System.out.println(getData111111111111111("005"));
    }
}
